import java.util.Timer;
import java.util.TimerTask;

/**
 * @Author: XXHH
 * @CreateTime: 2025-05-02
 */
public class Demo40 {
    public static void main(String[] args) {
        Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("Hello 3000");
                timer.cancel();
            }
        },3000);
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("Hello 2000");
            }
        },2000);
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("Hello 1000");

            }
        },1000);


    }
    public static void main2(String[] args) {
        TimerTask timerTask = new TimerTask() {
            @Override
            public void run() {
                System.out.println("Hello World");
            }
        };
        Timer timer = new Timer();
        timer.schedule(timerTask,3000);
    }
    public static void main1(String[] args) {
        Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("Hello world");
            }
        },300);

    }
}
